package com.tool.btn;

import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.HuangJpanel;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.GsonUtil;

import java.awt.*;
import java.awt.event.MouseEvent;

public class HuangBtn extends MoBanBtn{//黄大小
    private int caozuo;
    private HuangJpanel huangJpanel;
    private String text;
    public HuangBtn(String iconpath, int type, int caozuo,String text,HuangJpanel huangJpanel){
        super(iconpath, type);
        this.caozuo = caozuo;
        this.huangJpanel = huangJpanel;
        this.text=text;
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.setForeground(Color.white);
        setFont(UIUtils.TEXT_NAME_FONT);
        this.setText(text);
        this.setForeground(Color.YELLOW);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);

    }

    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {
        if (huangJpanel.getType()==0&&(caozuo==1||caozuo==2||caozuo==3||caozuo==4)){
            huangJpanel.getXuanyu().setVisible(false);
            huangJpanel.getJinbi().setVisible(false);
            huangJpanel.getDashuang().setVisible(false);
            huangJpanel.getDa().setVisible(false);
        }

        switch (caozuo)
        {
            case 1:
                huangJpanel.getXuanyu().setVisible(true);
                huangJpanel.setType(caozuo);
                break;
            case 2:
                huangJpanel.getJinbi().setVisible(true);
                huangJpanel.setType(caozuo);
                break;
            case 3:
                huangJpanel.getDashuang().setVisible(true);
                huangJpanel.setType(caozuo);
                break;
            case 4:
                huangJpanel.getDa().setVisible(true);
                huangJpanel.setType(caozuo);
                break;
            case 5:
            case 6:
                if (caozuo==5){
                    ZhuFrame.getZhuJpanel().addPrompt("#R您选择使用金币下注！！");
                    huangJpanel.getBaozi().setVisible(false);
                } else {
                    ZhuFrame.getZhuJpanel().addPrompt("#R您选择使用仙玉下注！！");
                    huangJpanel.getXiao().setVisible(false);
                }
                huangJpanel.setTpye1(caozuo);
                break;
            case 7:
                if (huangJpanel.getTpye1()==0) {
                    ZhuFrame.getZhuJpanel().addPrompt("#R请选择下注的类型！！");
                    return;
                }
                if (huangJpanel.getGold0()==0){
                    ZhuFrame.getZhuJpanel().addPrompt("#R请选择下注的金额！！");
                    return;
                }
                if (huangJpanel.getTpye1()==5){
                    if (huangJpanel.gold0 > RoleData.getRoleData().getLoginResult().getGold().longValue()){
                        ZhuFrame.getZhuJpanel().addPrompt("#R您带的现金不够哟！！");
                        huangJpanel.getBaozi().setVisible(true);
                        return;
                    }
                }else if (huangJpanel.getTpye1()==6){
                    if (huangJpanel.getGold0() > RoleData.getRoleData().getLoginResult().getCodecard().longValue()){
                        ZhuFrame.getZhuJpanel().addPrompt("#R您带的仙玉不够哟！！");
                        huangJpanel.getXiao().setVisible(true);
                        return;
                    }
                }
                if (huangJpanel.getType()==0){
                    ZhuFrame.getZhuJpanel().addPrompt("#R请选择彩头！！");
                    return;
                }
                SendMessageUntil.toServer(Agreement.getAgreement().HDXCPAgreement("HDX="+huangJpanel.getType()+"-"+huangJpanel.getTpye1()+"-"+huangJpanel.getGold0()+"-"+ HuangJpanel.tou+"-"+ HuangJpanel.tou1));

                huangJpanel.setTpye1(0);
                huangJpanel.setType(0);
                huangJpanel.setGold0(0);
                huangJpanel.getGold().setText(null);
                huangJpanel.getXuanyu().setVisible(true);
                huangJpanel.getJinbi().setVisible(true);
                huangJpanel.getDashuang().setVisible(true);
                huangJpanel.getDa().setVisible(true);
                huangJpanel.getXiao().setVisible(true);
                huangJpanel.getBaozi().setVisible(true);
                FormsManagement.HideForm(160);
                break;
            case 8:
                huangJpanel.setTpye1(0);
                huangJpanel.setType(0);
                huangJpanel.setGold0(0);
                huangJpanel.getGold().setText(null);
                huangJpanel.getXuanyu().setVisible(true);
                huangJpanel.getJinbi().setVisible(true);
                huangJpanel.getDashuang().setVisible(true);
                huangJpanel.getDa().setVisible(true);
                huangJpanel.getXiao().setVisible(true);
                huangJpanel.getBaozi().setVisible(true);
        }

    }

}